package com.cocotingo.snail.examples;

import javax.swing.JFrame;

import com.cocotingo.snail.View;
import com.cocotingo.snail.ViewContext;
import com.cocotingo.snail.template.previewer.TemplatePreviewer;

public class PreviewerExample {

	public static void main(String[] args) {

		// initials a JFrame
		JFrame mainFrame = new JFrame("Template Example");
		mainFrame.setSize(800, 600);
		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		// load a template XML file
		TemplatePreviewer loader = new TemplatePreviewer(mainFrame.getGraphicsConfiguration());
		try {
			loader.load(PreviewerExample.class.getResourceAsStream("SampleUI.xml"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		// instantiates a view by its name
		View view = loader.makeView("SampleView3");
		
		// show the view in JFrame
		ViewContext context = new ViewContext(mainFrame.getContentPane());
//		context.setDebugModeEnable(true);
		context.setRootView(view);
		mainFrame.setVisible(true);
	}

}
